<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>采购订单财务审核页面</title>
<style type="text/css">
	#addReload {
	position: absolute;
	top: 0%;
	z-index: 10000;
	background: rgb(0, 0, 0, 0.9);
	width: 100%;
	height: 100%;
	display: none;
}
.demoTable {
	z-in: 10px;
}

#addOperation {
	position: absolute;
	left: 30%;
	top: 15%;
	width: 40%;
	background: white;
}

.demo-carousel {
	height: 300px;
	line-height: 300px;
	text-align: center;
}
</style>
<link rel="stylesheet" href="../../../layui/css/layui.css" media="all">
</head>
<body>
	<div class="demoTable">
	  搜索:
	  <div class="layui-inline layui-form">
			<select name="conId" id="conId"
				autocomplete="off" class="layui-input">
				<option></option>
			</select>
	  </div>
	  <div class="layui-inline layui-form">
			<select name="poState" id="poState"
				autocomplete="off" class="layui-input">
				<option></option>
				<option value="未审核">未审核</option>
				<option value="已审核">已审核</option>
				<option value="未采购">未采购</option>
				<option value="已采购">已采购</option>
				<option value="未提交">未提交</option>
				<option value="已提交">已提交</option>
				<option value="未质检">未质检</option>
				<option value="已质检">已质检</option>
				<option value="未入库">未入库</option>
				<option value="已入库">已入库</option>
			</select>
	  </div>
	  <button class="layui-btn" data-type="reload">搜索</button>
	  <table class="layui-hide" id="purchaseOrder" lay-filter="demo"></table>
	</div>
 	<div id="addReload">
 		<div id="addOperation">
		 	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			  <legend>审核信息填写</legend>
			</fieldset>
			<form class="layui-form" id="shForm" action="../../../purchaseOrder/updateShzt.action" method="post"  >
			<input type="hidden" name="qwId" id="qwId">
			  <div class="layui-form-item">
			    <label class="layui-form-label">审核部门</label>
			    <div class="layui-input-block">
			      <input type="hidden" name="auditSection" value="财务部门">
			      <input type="text" maxlength="20" lay-verify="required" value="财务部门" autocomplete="off" class="layui-input layui-disabled" disabled style="width:280px;">
			    </div>
			  </div>
			  <div class="layui-form-item">
			    <label class="layui-form-label">订单名称</label>
			    <div class="layui-input-block">
			      <input type="text" name="roleCode" maxlength="20" value="材料采购订单"  autocomplete="off" class="layui-input layui-disabled" disabled style="width:280px;">
			    </div>
			  </div>
			  <div class="layui-form-item">
			    <label class="layui-form-label">是否通过</label>
			    <div class="layui-input-block" style="width:200px;">
			       <select name="auditPass"  lay-verify="required" lay-filter="isvas" lay-search="" id="isvas">
			       	  <option value="通过">是</option>
			          <option value="不通过">否</option>
			        </select>
			    </div>
			  </div>
			  <div class="layui-form-item layui-form-text" id="auditCause">
			    <label class="layui-form-label">审核意见</label>
				    <div class="layui-input-block">
				      <textarea placeholder="请输入内容" lay-verify="required" maxlength="20" name="auditCause" class="layui-textarea"></textarea>
				    </div>
			  </div>
			  <div class="layui-form-item">
			    <div class="layui-input-block">
			      <input type="submit" class="layui-btn" lay-submit="" lay-filter="roleAdd" value="提交">
			      <button id="closeAdd" type="reset" class="layui-btn layui-btn-primary" >取消</button>
			    </div>
			  </div>
		 </form>
	 </div>
 </div>
<script type="text/html" id="barDemo">
{{# if(d.shzt=="已审核"){ }}
  <a class="layui-btn layui-btn-warm    layui-btn-xs" lay-event="cgmx" id="cgmx">采购明细</a>
  <a class="layui-btn layui-btn-disabled  layui-btn-xs" lay-event="djsh" id="djsh">订单审核</a>
  <a class="layui-btn layui-btn-warm    layui-btn-xs" lay-event="shjl" id="shjl">审核记录</a>
{{# }else if(d.shzt=="未审核"){ }}
  <a class="layui-btn layui-btn-warm    layui-btn-xs" lay-event="cgmx" id="cgmx">采购明细</a>
  <a class="layui-btn layui-btn-normal  layui-btn-xs" lay-event="djsh" id="djsh">订单审核</a>
  <a class="layui-btn layui-btn-warm    layui-btn-xs" lay-event="shjl" id="shjl">审核记录</a>
{{# } }}
</script>
 
 <script type="text/javascript" src="../../../res/js/base.js"></script>
<script src="../../../layui/layui.js"></script>
<script>

layui.use(['laydate', 'laypage', 'layer', 'table', 'upload', 'element','form'], function(){
	  var laydate = layui.laydate //日期
	  ,laypage = layui.laypage //分页
	  layer = layui.layer //弹层
	  ,table = layui.table //表格
	  ,upload = layui.upload //上传
	  ,element = layui.element //元素操作
	  ,form=layui.form;
	  
	  //监听Tab切换
	  element.on('tab(demo)', function(data){
	    layer.msg('切换了：'+ this.innerHTML);
	    console.log(data);
	  });
	  
	  //执行一个 table 实例
	  table.render({
	     elem: '#purchaseOrder'
	    ,height: 490
	    ,url: getRootPath()+'purchaseOrder/findAll.action' //数据接口
	    ,page: true //开启分页
	    ,method:'post'
	    ,cols: [[ //表头
	       {type:'checkbox', fixed: 'left'}
	      /* ,{field: 'poId', title: '采购订单ID', width:120, fixed: 'left'}
	      ,{field: 'conId ', title: '采购订单ID', width:120, fixed: 'left'}*/
	      ,{field: 'gys', title: '合同供应商', width:150}
	      ,{field: 'poSumnum', title: '采购总重量(g)', width:100}
	      ,{field: 'poSumprice', title: '采购总价格', width:100}
	      ,{field: 'time', title: '采购时间', width:150}
	      ,{field: 'shzt', title: '审核状态', width:100}
	      ,{field: 'cgzt', title: '采购状态', width:100}
	      ,{field: 'tjzt', title: '提交状态', width:100}
	      ,{field: 'zjzt', title: '质检状态', width:100}
	      ,{field: 'rkzt', title: '入库状态', width:100}
	      ,{field: 'poRemark', title: '采购备注', width:150}
	      ,{fixed: 'right',title: '操作', width: 280, align:'center', toolbar: '#barDemo'}
	    ]]
	  	,id: 'testReload'
	  });
	  
	  //监听工具条
	  table.on('tool(demo)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
	    var data = obj.data //获得当前行数据
	    ,layEvent = obj.event; //获得 lay-event 对应的值
	    if(layEvent === 'djsh'){//删除操作
	      var poId=data.poId;
	      var shzt=data.shzt;
	      if(shzt=="未审核"){
	    	  var poId=data.poId;
		      $("#qwId").val(poId);
	    	  var poSumprice=data.poSumprice;
	    	  var url = "../../../purchaseOrder/cwPrice.action";
			  var data={poSumprice:poSumprice};
				  $.post(url,data,function(mes){
					if(mes.num<0){
						layer.msg('财务金额不足', {
							  icon: 1,
							  time: 2000 //1秒关闭（如果不配置，默认是3秒）
							}, function(){
								// location.reload(); // 页面刷新
						});
					}
					if(mes.num>=0){
				        form.render();
				        $('#addReload').css('display', 'block');
					}
			  });
	       }
	      if(shzt=="已审核"){
	    	  layer.msg('订单已审核', {
				  icon: 1,
				  time: 1500 //1秒关闭（如果不配置，默认是3秒）
				}, function(){
					 //location.reload(); // 页面刷新
			});
	      }
	    }else if(layEvent == 'cgmx'){//查询明细操作
	    	var poId=data.poId;
	    	layer.open({
				  type: 	2,
				  area : ['100%' , '100%'],//弹出框大小
				  shift:1,//弹出框动画效果
				  content: 'poBreakdown.html?poId='+poId //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
			}); 
	    }else if(layEvent == 'shjl'){//查询明细操作
	    	var poId=data.poId;
	    	layer.open({
				  type: 	2,
				  area : ['100%' , '100%'],//弹出框大小
				  shift:1,//弹出框动画效果
				  content: 'shjl.html?poId='+poId //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
			}); 
	    }
	  });
	  
	  //条件查询
	  var $ = layui.$;
			  
	  $('.demoTable .layui-btn').on('click', function(){
		 var conId = $('#conId');
		 var poState=$('#poState');
		 //执行重载
	     table.reload('testReload', {
	       page: {
	         curr: 1 //重新从第 1 页开始
	       }
	       ,where: {
	    	   conId: conId.val(),
	    	   poState: poState.val()
	       }
	     });
	  });
	  $('#closeAdd').on('click', function() {
			$('#addReload').css('display', 'none');
		});
	  
	    var url = "../../../contractTableAction/findAll.action";
		$.post(url,null,function(data){
			for(var i=0;i<data.length;i++){
				$("#conId").append("<option value="+data[i].conId+">"+data[i].conTwo+"</option>");
			}
			//form表单重新渲染
			form.render();
		});
	});
	  
</script>
</body>
</html>